<?php

/**
 * \file
 * Classe `Button`.
 */

namespace pilar\Forms /* \cond */ ; /* \endcond */
{

/**
 * Bouton de validation d'un formulaire.
 *
 * \since 03/12/2008
 * \author Matthieu OVIEDO <matthieu.oviedo@gmail.com>
 */
class Button extends \object implements Atom {

/**
 * Formulaire parent.
 *
 * \since 03/12/2008
 */
private $_parentForm;

protected function loadDefaultParams() {
 parent::loadDefaultParams();

 $this->params->define(array(
  'name' => '_button', // Nom.
  'value' => 'ok', // Valeur.
  'label' => 'OK', // Libellé.
 ));
}


public function onParentFormChanged(Form $f) {
 $this->_parentForm = $f;
}


public function subMembers() {
 return array(); // Un bouton n'a aucun sous-membre.
}


public function domNode($domDoc) {
 $domButton = $domDoc->createElement('button');
 $domButton->setAttribute('id', $this->_parentForm->globalId($this->get('name')));
 $domButton->setAttribute('name', $this->_parentForm->globalId($this->get('name')));
 if($this->get('value') != '') {
  $domButton->setAttribute('value', $this->get('value'));
 }
 $domButton->setAttribute('label', $this->get('label'));

 return $domButton;
}


} // Class.

} // Namespace.

?>
